package com.joinway.framework.jsondoc.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jsondoc.core.pojo.JSONDoc;
import org.jsondoc.core.scanner.JSONDocScanner;
import org.jsondoc.springmvc.controller.JSONDocController;
import org.jsondoc.springmvc.scanner.SpringJSONDocScanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Deprecated
@RestController
class JsonDocController {
	private final static Logger log = LoggerFactory.getLogger(JsonDocController.class);
	
	private String version = "1.1.12";
	private JSONDocScanner jsondocScanner = new SpringJSONDocScanner();

//	public final static String JSONDOC_DEFAULT_PATH = "/jsondoc";

	@RequestMapping(value = JSONDocController.JSONDOC_DEFAULT_PATH, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public JSONDoc getApi(HttpServletRequest request) {
//		String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/"
		String basePath = request.getScheme() + "://" + request.getServerName() + request.getContextPath() + "/";
		
		List<String> packages = new ArrayList<>();
		packages.add("com.joinway");
		log.info("init jsondoc version [{}] by scanning {}, doc path [{}]", version, packages, basePath);
		
//		return jsondocScanner.getJSONDoc(version, basePath, packages);
		return null;
	}
}
